var Toolbar = Vue.component('toolbar', {
    props: {
        cartlen: {
            type: Number,
            default: 0
        },
        active: {
            type: String,
            default: 'index'
        },

    },
    template: `
    <div class="toolbar tabbar tabbar-labels">
        <div class="toolbar-inner">
            <a href="index.html" class="tab-link ">
                <i class="fa fa-2x fa-shopping-basket" :class="{'color-blue':active=='index'}"></i>
                <span class="tabbar-label">首页</span>
            </a>
            <!--<a href="index.html" class="tab-link ">
                <i class="fa fa-2x fa-play" ></i>
                <span class="tabbar-label">视频</span>
            < /a>-->
            <!--<a href="videolist.html" class="tab-link">
                <i class="fa fa-2x fa-video-camera" :class="{'color-blue':active=='videolist'}"></i>
                <span class="tabbar-label">做菜</span>
            </a>-->
            <a href="###" @click.prevent="gotoPage('orderlist.html?cs=all')" class="tab-link">
                <i class="fa fa-2x fa-list-alt" :class="{'color-blue':active=='order'}"></i>
                <span class="tabbar-label">订单</span>
            </a>
            <a href="cart.html" class="tab-link">
                <i class="fa fa-2x fa-shopping-cart footer-cart" :class="{'color-blue':cartlen>0||active=='cart'}">
                    <span class="badge bg-orange cart-num" :class="{'cart-num-show':cartlen>0}">{{cartlen}}</span>
                </i>
                <span class="tabbar-label">购物车</span>
            </a>
            <a href="###" @click.prevent="gotoPage('user.html')" class="tab-link">
                <i class="fa fa-2x fa-user" :class="{'color-blue':active=='user'}"></i>
                <span class="tabbar-label">会员</span>
            </a>
        </div>
    </div>
    `,
    data: function () {
        return {
            msg: null
        }
    },
    methods: {


        gotoPage(url) {
            var self = this;
            ajax.getUserInfo({
                type: 'post',
                param: {
                    token: localStorage.token
                },
                cb(data) {
                    if (data.rcode == cfg.rcode.NOREQ) {
                        tip.info('用户未注册');
                        delete localStorage.token;
                        window.location.href = 'register.html';
                    } else {
                        localStorage.address = data.data.address;
                        localStorage.balance = data.data.balance;
                        localStorage.username = data.data.username;
                        localStorage.userLevel = data.data.userLevel;
                        localStorage.nickname = data.data.nickname;
                        localStorage.url = data.data.headImgUrl;
                        window.location.href = url;
                    }

                }
            })
        }
    },
});